#include<stdio.h>
#include<string.h>
#include<stdlib.h>

void ladderPrint(int * arr,int length){

    int index = 0;
    for(;index < length-1;index++){

        printf("%d + ",arr[index]);
    }
    printf("%d.\n",arr[length-1]);  // 避免输出多余的'+'号
}

void composeLadder(int * arr,int ind,int n){
    if(n <= 0){
        
        ladderPrint(arr,ind);
        return;
    }
    int val = 1;
    int count = 3;
    if(n <= 3){

        count = n;
    }
    for(;val <= count;++val){

        arr[ind] = val;
        composeLadder(arr,ind+1,n-val);
    }
}

int
main(int argc,char * argv[]){

    if(argc!=2){

        printf("need one position integer.\n");
        return EXIT_FAILURE;
    }
    int n = (int)strtol(argv[1],NULL,10);
    int * arr = (int*)malloc(sizeof(int)*n);
    composeLadder(arr,0,n);
    free(arr);
    return EXIT_SUCCESS;
}